var TabSwitchover = new Class({
	tabs : [],
	activeTabClass : '',
	contents : [],
	map : [],
	/**
	 * 初始化
	 * 
	 * @param {string} tabContainerSelector     选项卡的选择器
	 * @param {string} contentContainerSelector 内容的选择器
	 * 
	 * @returns {void} void
	 */
	initialize : function (tabContainerSelector, contentContainerSelector) {
		this.setTabs(tabContainerSelector);
		this.setContents(contentContainerSelector);
		this.setActiveTabClass();
		this.setMap();
		var self = this;
		this.map.each(function (map, index) {
			map.tab.addEvent('click', function (event) {
				self.switchover(index);
				event.preventDefault();
			});
		});
	},
	//设置选项卡
	setTabs : function (tabContainerSelector) {
		this.tabs = $$(tabContainerSelector);
	},
	//设置内容展示块
	setContents : function (contentContainerSelector) {
		this.contents = $$(contentContainerSelector);
	},
	//设置选项卡和内容之间的映射关系
	setMap : function (mapFunc) {
		if($defined(mapFunc) == false) {
			var self = this;
			this.tabs.each(function (tab, index) {
				self.map[index] = {
					tab : self.tabs[index],
					content : self.contents[index]
				};
			});
		} else {
			this.map = eval(mapFunc + '(' + this.tabs + ',' + this.contents + ');');
		}
	},
	//设置激活选项卡的Class
	setActiveTabClass : function (activeTabClass) {
		this.activeTabClass = $defined(activeTabClass) == false ? 'activeTab' : activeTabClass;
	},
	//切换选项卡
	switchover : function (activeIndex) {
		if ($defined(this.map[activeIndex]) === false) {
			return false;
		}
		var self = this;
		this.map.each(function (map, index) {
			if (activeIndex == index) {
				map.tab.addClass(self.activeTabClass);
				map.content.setStyles({display : ''});
			} else {
				map.tab.removeClass(self.activeTabClass);
				map.content.setStyles({display : 'none'});
			}
		});
	}
});